fix: render standard-test assertion messages correctly - #1141
fix: render standard-test assertion messages correctly#1141devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Co-Authored-By: bot_apk <apk@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1788275255-fix-standard-test-assert-messages#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1788275255-fix-standard-test-assert-messagesPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes two assertion messages in the CDK standard test suites that previously printed literal {...} instead of interpolated values, improving the usefulness of test_spec / test_check failure output. It also adds a unit-test guard to prevent similar assertion-message rendering mistakes from being introduced in airbyte_cdk/test/standard_tests.
Changes:
- Fix
connector_base.pyassertion message by ensuring the fragment containing{result.connection_status_messages!s}is an f-string. - Fix
source_base.pyassertion message by replacing a tuple assert-message with a single interpolated string includingresult.errors. - Add an AST-based regression test to detect tuple assert messages and placeholder-like
{...}substrings that would render literally.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| unit_tests/test/test_assertion_messages.py | Adds an AST-based regression guard against non-renderable assert messages in standard tests. |
| airbyte_cdk/test/standard_tests/source_base.py | Fixes test_spec assertion message to interpolate counts/errors correctly and avoids tuple messages. |
| airbyte_cdk/test/standard_tests/connector_base.py | Fixes test_check assertion message so the “Got:” portion interpolates correctly. |
Suppressed comments (1)
unit_tests/test/test_assertion_messages.py:64
- Same as above: reporting node.lineno will point at the assert statement rather than the start of the msg expression, making failures easier to locate.
problems.append(
f"{source_file.name}:{node.msg.lineno}: assert message contains "
f"{placeholder} but the fragment is missing the `f` prefix"
)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: bot_apk <apk@cognition.ai>
PyTest Results (Full)4 375 tests 4 363 ✅ 11m 33s ⏱️ Results for commit d21b65e. |
|
CI note for reviewers: all required checks are green (Pytest 3.10–3.13, MyPy, Ruff lint/format, Build & Inspect). The one failure is the downstream The same job also failed on an unrelated recent CDK PR branch ( |
Summary
Two assertion messages in the standard test suites never rendered their values, so
test_spec/test_checkfailures printed literal braces instead of the counts that explain the failure.Resolves (in part) https://github.com/airbytehq/airbyte-internal-issues/issues/17132:
Behavior called out for review: in
source_base.pythe assert message was a tuple, which is always truthy as an assert message and printed as a tuple repr. It is now a single interpolated string that still includesresult.errors. This goes slightly beyond the literal reported defect (the missingf), so flagging it explicitly rather than burying it — happy to split if you'd rather keep the tuple.The new
unit_tests/test/test_assertion_messages.pyis a regression guard rather than a behavioral test: it AST-walks every module underairbyte_cdk/test/standard_testsand fails on anyassertmessage that is a tuple, or that contains a{placeholder}-looking substring in a fragment missing thefprefix. Verified it fails on both pre-fix lines (connector_base.py:117,source_base.py:98) and passes after.The other three defects in the issue are in
airbytehq/airbyte(poe-tasks/*.toml) and are handled by a separate PR linked from the issue.Test plan:
poetry run pytest unit_tests/test -q→ 124 passed;poetry run ruff check/ruff format --checkclean on the touched paths.Link to Devin session: https://app.devin.ai/sessions/7effc4c9e1fa40f1bf8f6c7aadac0d62
Open in Devin Desktop: https://app.devin.ai/desktop/session/7effc4c9e1fa40f1bf8f6c7aadac0d62?variant=devin